package com.smedi.ismedi.web.starter.config;

import com.smedi.ismedi.authority.starter.context.CurrentUserHelper;
import com.smedi.ismedi.authority.starter.feign.AuthorityAccessFeignClient;
import com.smedi.ismedi.authority.starter.util.JsonHelper;
import com.smedi.ismedi.authority.starter.util.VerifyHelper;
import com.smedi.ismedi.web.starter.handler.CatchFromRequestSessionAttributeHandler;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Slf4j
@Configuration
@RequiredArgsConstructor
@Order(value = -1)
public class ForwardInterceptorConfig implements WebMvcConfigurer {

    @Bean
    public CatchFromRequestSessionAttributeHandler CatchFromRequestSessionAttributeInterceptor() {
        return new CatchFromRequestSessionAttributeHandler();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        log.debug("添加forward转发的头参数拦截器");
        InterceptorRegistration config = registry.addInterceptor(this.CatchFromRequestSessionAttributeInterceptor());
        config.addPathPatterns("/**");
    }
}
